import React, { Component } from 'react'
import PropTypes from 'prop-types'
import ListItem from '../comment-list-item'

export default class CommentList extends Component {
    /**
     * 属性验证
     */
    static propTypes = {
        comments: PropTypes.array.isRequired,
        deleteComment: PropTypes.func.isRequired
    }
    render() {
        const {comments} = this.props
        return (
            <div>
                <h3>评论回复</h3>
                <h4 style={{display:comments.length < 1? 'block':'none'}}>无数据</h4>
                { 
                    comments.map((item,index)=>{
                        return (
                            <ListItem deleteComment={this.props.deleteComment} key={index} item={item} index={index}/>
                        )
                    })
                }
                
            </div>
        )
    }
}
